feat: Stripe-style configuration, DSL builders, and decomposed docs#68
Merged
Conversation
Introduces a convenience layer on top of the existing Options-based API: - Configuration: module-level config via Forwardable (ClaudeAgent.model=), block-based configure, to_options merge with per-request overrides - Entry points: ClaudeAgent.ask (one-shot) and ClaudeAgent.chat (multi-turn) - PermissionPolicy: declarative allow/deny/matching DSL compiling to can_use_tool - HookRegistry: Ruby method names mapping to 22 CLI events, additive merge - Message module: text_content, pattern matching, prepended into all types - EventHandler.define: block-based DSL for handler definitions - MCP Server block DSL and symbol type shortcuts in Tool schema - Session resource: retrieve (raises), rename/tag/fork/reload/resume methods - NotFoundError added to error hierarchy - README trimmed to 120-line primer, full docs decomposed into 14 guides in docs/ - CLAUDE.md and conventions.md updated with new patterns
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds an idiomatic Ruby convenience layer on top of the existing Options-based API, and decomposes the monolithic README into 14 focused documentation guides.
Why
The SDK's public API felt like a translated TypeScript SDK rather than idiomatic Ruby. This introduces Stripe-inspired ergonomics — module-level config, declarative DSL builders, and simple entry points — while keeping the existing API fully intact and backward compatible.
The 1,600-line README was too large to navigate. Splitting into
docs/makes each topic discoverable and maintainable.How
Convenience layer (additive, non-breaking)
ClaudeAgent.model = "opus",ClaudeAgent.configure { |c| ... },Configuration#to_optionsmerges global defaults with per-request overridesClaudeAgent.ask(prompt)(one-shot, returns TurnResult) andClaudeAgent.chat { |c| ... }(multi-turn, auto-cleanup)allow/deny/allow_matching/deny_matchingDSL compiling tocan_use_toollambdabefore_tool_use,on_session_start, etc.) mapping to 22 CLI events, additive mergetext_content,session_message?,identifiable?, pattern matching viadeconstruct_keys— prepended into all 22 message types and 8 content blocksServer.new(name:) { |s| s.tool(...) }and symbol type shortcuts (:number,:string, etc.)Session.retrieve(raises NotFoundError), instance methodsrename,tag_session,fork,reload,resume;Session.findswitched from full scan to targetedGetSessionInfolookupDocumentation
docs/: getting-started, configuration, conversations, queries, permissions, hooks, mcp, events, messages, sessions, client, errors, logging, architecture.claude/rules/conventions.mdupdated with Stripe-style config, DSL builder, and Data.define prepend patternsBug fix
SessionPaths.realpath— encode ASCII-8BIT paths to UTF-8 beforeunicode_normalize(fixesEncoding::CompatibilityErrorwhen sessioncwdcomes from JSONL)Tests